﻿Function Get-HyperVHostName($credential)
{
    Import-Module -Force .\libHyperVCluster.psm1
    $hyperVHostNames=@()
    #Read clusters definition
    [xml]$hyperVInfrastructureDefinition=Get-Content .\HyperVInfrastructure.xml
    
    $hyperVClusters=$hyperVInfrastructureDefinition.SelectNodes("/HyperVConfiguration/HyperVClusters/HyperVCluster")

    #Discover cluster nodes and add them to the list
    foreach($hyperVCluster in $hyperVClusters)
    {
        $hyperVHostNames+=Get-HyperVClusterNodes -clusterName $hyperVCluster.Name -credential $credential | Select Cluster,Name
        
    }
    
    $hyperVStandaloneHostNames=$hyperVInfrastructureDefinition.SelectNodes("/HyperVConfiguration//HyperVStandaloneHosts/HyperVStandaloneHost")

    foreach($hyperVStandaloneHostName in $hyperVStandaloneHostNames)
    {
        $hyperVHostNames+=New-Object -TypeName PSObject -Property @{Cluster="Standalone";Name=$hyperVStandaloneHostName.Name;}
    }

    $hyperVHostNames
}

